﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBAccess;
using SSPharma.Model;
using System.Data.Common;
using SSPharma.Common;


namespace SSPharma.Biz
{
    public class BizMH_YeuCauMuaHang 
    {
        static public List<MH_YeuCauMuahangHeader> GetYeuCauMuaHangBySoYeuCau(string str_SoYeuCau)
        {
            List<MH_YeuCauMuahangHeader> lsYeuCauMuaHang = new List<MH_YeuCauMuahangHeader>();
            StringBuilder strSQL = new StringBuilder();
            strSQL.Append(" SELECT  ID_SQ	    ,YeuCauMH_ID	,SoChungTu	,NgayChungTu	,NgayCan	");
            strSQL.Append("         ,LoaiYeuCau	,MaYeuCauCha	,MaBoPhan	,MaNhanVien	    ,GhiChu	    ");
            strSQL.Append("         ,TinhTrangTH	,TinhTrang	");
            strSQL.Append(" FROM    MH_YeuCauMuahangHeader with(nolock)");
            strSQL.Append(" WHERE   SoChungTu = @str_SoYeuCau");
           // strSQL.Append(" vMH_YeuCauMuaHang");
            SQLServer.Param[] Params = new SQLServer.Param[1];
            //Params[0] = new SQLServer.Param("@str_SoYeuCau", str_SoYeuCau);

            using (DbDataReader dataReader = Global.DataFactory.Reader(strSQL.ToString(), Params))
            {
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        MH_YeuCauMuahangHeader YCMH = new MH_YeuCauMuahangHeader();
                        YCMH.ID_SQ =dataReader.GetInt64(0);
                        YCMH.YeuCauMH_ID= dataReader.IsDBNull(1) ? string.Empty : dataReader.GetString(1);
                        YCMH.SoChungTu= dataReader.IsDBNull(2) ? string.Empty : dataReader.GetString(2);
                        YCMH.NgayChungTu=  dataReader.GetDateTime(3);
                        YCMH.NgayCan=  dataReader.GetDateTime(4);
                        YCMH.LoaiYeuCau= dataReader.IsDBNull(5) ? string.Empty : dataReader.GetString(5);
                        YCMH.MaYeuCauCha= dataReader.IsDBNull(6) ? string.Empty : dataReader.GetString(6);
                        YCMH.MaBoPhan= dataReader.IsDBNull(7) ? string.Empty : dataReader.GetString(7);
                        YCMH.MaNhanVien= dataReader.IsDBNull(8) ? string.Empty : dataReader.GetString(8);
                        YCMH.GhiChu= dataReader.IsDBNull(9) ? string.Empty : dataReader.GetString(9);
                        YCMH.TinhTrangTH= dataReader.IsDBNull(10) ? string.Empty : dataReader.GetString(10);
                        YCMH.TinhTrang= dataReader.IsDBNull(11) ? string.Empty : dataReader.GetString(11);

                        lsYeuCauMuaHang.Add(YCMH);
                    }
                }
            }

            return lsYeuCauMuaHang;
        }

        static public string abcd()
        {
            return "afssdfs";
        }

        //static public AddNew


    }
}
